package com.brillilab.service.job.lab;

import com.brillilab.service.logic.message.MessageLogic;
import com.brillilab.service.module.message.producer.MessageProducer;
import com.brillilab.service.module.message.template.impl.lab.BeforeLabExpireTemplate;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BeforeLabExpireJob implements Job {

    @Autowired
    private MessageProducer producer;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap dataMap=context.getJobDetail().getJobDataMap();
        Long labId=dataMap.getLong("labId");
        Long labMemberId=dataMap.getLong("labMemberId");
        Long ownerId=dataMap.getLong("ownerId");
        Long days=dataMap.getLong("days");
        //TODO 消息推送逻辑
        producer.sendMessagePush(new BeforeLabExpireTemplate(labId,ownerId,labMemberId,days,labId));
    }
}
